export const extend = Object.assign

export const isString = (val) => typeof val === 'string'

export const isObject = (val) => {
  return val !== null && typeof val === 'object'
}

export const isFunction = (val) => typeof val === 'function'

export const isArray = (val) => {
  return Array.isArray(val)
}

export const hasChanged = (a, b) => {
  return !Object.is(a, b)
}
export * from './ShapeFlags'

export const isOn = (key) => /^on[A-Z]/.test(key)

export const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)

// add->Add
const capitialize = (str) => {
  return str.charAt(0).toUpperCase() + str.slice(1)
}

// add->onAdd
export const toHandlerKey = (str) => {
  return str ? 'on' + capitialize(str) : ''
}

// add-foo ->  addFoo
export const camelize = (str) => {
  return str.replace(/-(\w)/g, (_, c) => {
    return c ? c.toUpperCase() : ''
  })
}

export const EMPTY_OBJ = {}
